/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package br.os.rh.telas;

import br.os.rh.util.Ativo;

/**
 *
 * @author 'Pedro
 */
public class TelaPrincipal extends javax.swing.JFrame {

    /**
     * Creates new form TelaPrincipal
     */
    public TelaPrincipal() {
        initComponents();
        setLocationRelativeTo(null);
        permissaoFalse();
        permissaoAdm();
        permissaoRH();
        permissaoCoordenador();
        permissaoSecretaria();
        setTitle("OSRH");
        preencheLabel();
    }
    
    private void permissaoCoordenador(){
        if (Ativo.getUsuario().getTipo().equals("Coordenador de Curso")) {
            mmDisciplina.setVisible(true);
            mmLotacao.setVisible(true);
            mRelatorios.setVisible(false);
        }
        
    }
    
    private void permissaoSecretaria(){
        if (Ativo.getUsuario().getTipo().equals("Secretária Professores")) {
            mCadastro.setVisible(false);
            mRelatorios.setVisible(false);
            mmPontoProfessores.setVisible(true);
        }
        
    }
    
    private void preencheLabel(){
       String str = "Usuário: "+Ativo.getUsuario().getNome()+
               " | Tipo: "+Ativo.getUsuario().getTipo();
       if(!Ativo.getUsuario().isAdministrador()){
           str+=" | Período: "+Ativo.getPeriodo().getDescricao();
       }
       str+=" | Versão 2.3";
       lblInformativo.setText(str);
    }

    private void permissaoFalse() {
        mmUsuario.setVisible(false);
        mmPeriodo.setVisible(false);
        mmDisciplina.setVisible(false);
        mmFuncionario.setVisible(false);
        mmHorarios.setVisible(false);
        mmSalario.setVisible(false);
        mmRelProfLotacao.setVisible(false);
        mmRelPlanilhaProfessores.setVisible(false);
        mmCurso.setVisible(false);
        mmLotacao.setVisible(false);
        mmSemestre.setVisible(false);
        mmPontoProfessores.setVisible(false);
    }

    private void permissaoAdm() {
        if (Ativo.getUsuario().isAdministrador()) {
            mmSemestre.setVisible(true);
            mmCurso.setVisible(true);
            mmUsuario.setVisible(true);
            mmPeriodo.setVisible(true);
            mMovimentacao.setVisible(false);
            mRelatorios.setVisible(false);
        }
    }

    private void permissaoRH() {
        if (Ativo.getUsuario().getTipo().equals("RH")) {
            mmFuncionario.setVisible(true);
            mmHorarios.setVisible(true);
            mmSalario.setVisible(true);
            mmRelProfLotacao.setVisible(true);
            mmRelPlanilhaProfessores.setVisible(true);
            mmCurso.setVisible(true);
            mmSemestre.setVisible(true);
        }

    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        lblInformativo = new javax.swing.JLabel();
        jMenuBar1 = new javax.swing.JMenuBar();
        mCadastro = new javax.swing.JMenu();
        mmCurso = new javax.swing.JMenuItem();
        mmDisciplina = new javax.swing.JMenuItem();
        mmFuncionario = new javax.swing.JMenuItem();
        mmHorarios = new javax.swing.JMenuItem();
        mmPeriodo = new javax.swing.JMenuItem();
        mmSemestre = new javax.swing.JMenuItem();
        mmUsuario = new javax.swing.JMenuItem();
        mMovimentacao = new javax.swing.JMenu();
        mmLotacao = new javax.swing.JMenuItem();
        mmSalario = new javax.swing.JMenuItem();
        mmPontoProfessores = new javax.swing.JMenuItem();
        mRelatorios = new javax.swing.JMenu();
        mmRelProfLotacao = new javax.swing.JMenuItem();
        mmRelPlanilhaProfessores = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setResizable(false);

        jPanel1.setBackground(new java.awt.Color(255, 255, 255));
        jPanel1.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/br/os/rh/imagens/nexaspng maior.png"))); // NOI18N
        jPanel1.add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(180, 90, 380, 350));

        lblInformativo.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        lblInformativo.setText("jLabel2");
        jPanel1.add(lblInformativo, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 510, -1, -1));

        mCadastro.setText("Cadastros");

        mmCurso.setText("Curso");
        mmCurso.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                mmCursoActionPerformed(evt);
            }
        });
        mCadastro.add(mmCurso);

        mmDisciplina.setText("Disciplina");
        mmDisciplina.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                mmDisciplinaActionPerformed(evt);
            }
        });
        mCadastro.add(mmDisciplina);

        mmFuncionario.setText("Funcionário");
        mmFuncionario.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                mmFuncionarioActionPerformed(evt);
            }
        });
        mCadastro.add(mmFuncionario);

        mmHorarios.setText("Horários");
        mmHorarios.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                mmHorariosActionPerformed(evt);
            }
        });
        mCadastro.add(mmHorarios);

        mmPeriodo.setText("Período");
        mmPeriodo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                mmPeriodoActionPerformed(evt);
            }
        });
        mCadastro.add(mmPeriodo);

        mmSemestre.setText("Semestre");
        mmSemestre.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                mmSemestreActionPerformed(evt);
            }
        });
        mCadastro.add(mmSemestre);

        mmUsuario.setText("Usuário");
        mmUsuario.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                mmUsuarioActionPerformed(evt);
            }
        });
        mCadastro.add(mmUsuario);

        jMenuBar1.add(mCadastro);

        mMovimentacao.setText("Movimentação");

        mmLotacao.setText("Lotação");
        mmLotacao.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                mmLotacaoActionPerformed(evt);
            }
        });
        mMovimentacao.add(mmLotacao);

        mmSalario.setText("Salário");
        mmSalario.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                mmSalarioActionPerformed(evt);
            }
        });
        mMovimentacao.add(mmSalario);

        mmPontoProfessores.setText("Ponto Professores");
        mmPontoProfessores.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                mmPontoProfessoresActionPerformed(evt);
            }
        });
        mMovimentacao.add(mmPontoProfessores);

        jMenuBar1.add(mMovimentacao);

        mRelatorios.setText("Relatórios");

        mmRelProfLotacao.setText("Professores/Lotação");
        mmRelProfLotacao.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                mmRelProfLotacaoActionPerformed(evt);
            }
        });
        mRelatorios.add(mmRelProfLotacao);

        mmRelPlanilhaProfessores.setText("Planilha Professores");
        mmRelPlanilhaProfessores.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                mmRelPlanilhaProfessoresActionPerformed(evt);
            }
        });
        mRelatorios.add(mmRelPlanilhaProfessores);

        jMenuBar1.add(mRelatorios);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void mmUsuarioActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mmUsuarioActionPerformed
        // TODO add your handling code here:
        TelaUsuario tu = new TelaUsuario();
        tu.setVisible(true);
    }//GEN-LAST:event_mmUsuarioActionPerformed

    private void mmPeriodoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mmPeriodoActionPerformed
        // TODO add your handling code here:
        TelaPeriodo tp = new TelaPeriodo();
        tp.setVisible(true);
    }//GEN-LAST:event_mmPeriodoActionPerformed

    private void mmDisciplinaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mmDisciplinaActionPerformed
        // TODO add your handling code here:
        TelaDisciplina td = new TelaDisciplina();
        td.setVisible(true);
    }//GEN-LAST:event_mmDisciplinaActionPerformed

    private void mmFuncionarioActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mmFuncionarioActionPerformed
        // TODO add your handling code here:
        TelaFuncionario tf = new TelaFuncionario();
        tf.setVisible(true);
    }//GEN-LAST:event_mmFuncionarioActionPerformed

    private void mmSalarioActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mmSalarioActionPerformed
        // TODO add your handling code here:
        TelaSalario ts = new TelaSalario();
        ts.setVisible(true);
    }//GEN-LAST:event_mmSalarioActionPerformed

    private void mmHorariosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mmHorariosActionPerformed
        // TODO add your handling code here:
        TelaHorario th = new TelaHorario();
        th.setVisible(true);
    }//GEN-LAST:event_mmHorariosActionPerformed

    private void mmRelProfLotacaoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mmRelProfLotacaoActionPerformed
        // TODO add your handling code here:
        TelaRelatorioProfessoresLotacao trpl = new TelaRelatorioProfessoresLotacao();
        trpl.setVisible(true);
    }//GEN-LAST:event_mmRelProfLotacaoActionPerformed

    private void mmRelPlanilhaProfessoresActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mmRelPlanilhaProfessoresActionPerformed
        // TODO add your handling code here:
        TelaGeraPlanilhaFolhaProfessores tgpfp = new TelaGeraPlanilhaFolhaProfessores();
        tgpfp.setVisible(true);
    }//GEN-LAST:event_mmRelPlanilhaProfessoresActionPerformed

    private void mmCursoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mmCursoActionPerformed
        // TODO add your handling code here:
        TelaCurso tc = new TelaCurso();
        tc.setVisible(true);
    }//GEN-LAST:event_mmCursoActionPerformed

    private void mmSemestreActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mmSemestreActionPerformed
        // TODO add your handling code here:
        TelaSemestre ts = new TelaSemestre();
        ts.setVisible(true);
    }//GEN-LAST:event_mmSemestreActionPerformed

    private void mmLotacaoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mmLotacaoActionPerformed
        // TODO add your handling code here:
        TelaLotacao tl = new TelaLotacao();
        tl.setVisible(true);
    }//GEN-LAST:event_mmLotacaoActionPerformed

    private void mmPontoProfessoresActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mmPontoProfessoresActionPerformed
        // TODO add your handling code here:
        TelaMarcarPonto tmp = new TelaMarcarPonto();
        tmp.setVisible(true);
    }//GEN-LAST:event_mmPontoProfessoresActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(TelaPrincipal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(TelaPrincipal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(TelaPrincipal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(TelaPrincipal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new TelaPrincipal().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel jLabel1;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JLabel lblInformativo;
    private javax.swing.JMenu mCadastro;
    private javax.swing.JMenu mMovimentacao;
    private javax.swing.JMenu mRelatorios;
    private javax.swing.JMenuItem mmCurso;
    private javax.swing.JMenuItem mmDisciplina;
    private javax.swing.JMenuItem mmFuncionario;
    private javax.swing.JMenuItem mmHorarios;
    private javax.swing.JMenuItem mmLotacao;
    private javax.swing.JMenuItem mmPeriodo;
    private javax.swing.JMenuItem mmPontoProfessores;
    private javax.swing.JMenuItem mmRelPlanilhaProfessores;
    private javax.swing.JMenuItem mmRelProfLotacao;
    private javax.swing.JMenuItem mmSalario;
    private javax.swing.JMenuItem mmSemestre;
    private javax.swing.JMenuItem mmUsuario;
    // End of variables declaration//GEN-END:variables
}
